package com.fap.util;

import java.util.Map;

import org.springframework.web.context.WebApplicationContext;

import com.fap.search.meta.MetaRepository;
import com.fap.spring.SpringContextListener;

public class BeanUtil {
	
	private static WebApplicationContext _context;
	
	private static WebApplicationContext getContext(){
		if(_context==null)
			_context = SpringContextListener.getApplicationContext();
		return _context;
	}
	
	public static Object getBean(Class beanClass){
		Map<String, MetaRepository> beans = getContext().getBeansOfType(beanClass);
		for(String key: beans.keySet()){
			return beans.get(key);
		}
		return null;
	}
}
